<?php
/**
 * Created by PhpStorm.
 * User: HS032
 * Date: 2020/11/5
 * Time: 16:37
 */

namespace ticket\modules\backend\controllers;


use ticket\libs\Tools;
use ticket\modules\backend\models\CategoryInfo;
use Yii;


class CategoryInfoController extends BasicController
{

    public function actionCategoryInfo()
    {
        $get = Yii::$app->request->get();
        $cateInfoModel = new CategoryInfo();
        $info = $cateInfoModel->getInfo($get);
        return Tools::showRes(0,'success',[
            'info' => $info,
        ]);
    }

    public function actionSetCategory()
    {
        if (Yii::$app->request->isPost){
            $post = Yii::$app->request->post();
            $cateInfoModel = new CategoryInfo();
            if (!$cateInfoModel->setInfo($post)){
                if ($cateInfoModel->hasErrors()){
                    return Tools::showRes(10404,$cateInfoModel->getErrors());
                }else{
                    return Tools::showRes(10405,'添加失败');
                }
            }
            return Tools::showRes(0,'更新成功');
        }
    }


}